import csv
from datetime import datetime
import matplotlib.pyplot as plt

filename = 'data/death_valley_2018_simple.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)

    lows, highs,dates = [], [], []

    #收集数据
    for row in reader:
        date = datetime.strptime(row[2], '%Y-%m-%d')
        try:
            high = int(row[4])
            low = int(row[5])

        except:
            print(f"Missing data for {date}")
        else:
            highs.append(high)
            lows.append(low)
            dates.append(date)

#数据可视化
plt.style.use('seaborn')
fig,ax =plt.subplots(dpi=128)
ax.plot(dates,lows,c='blue',alpha=0.5)
ax.plot(dates,highs,c='red',alpha=0.5)
ax.fill_between(dates,lows,highs,facecolor='blue',alpha=0.1)

#设置标题
ax.set_title("The temperate in sitka",fontsize=24)
ax.set_xlabel('',fontsize=14)
ax.set_ylabel('Temperate(F)',fontsize=14)

plt.show()